using Godot;
using System;

public partial class Start : Node2D
{
	#region 子组件
	AnimationPlayer animationPlayer;
	Panel panel;

	Button buttonStart;
	Button buttonLoad;
	Button buttonExit;
	#endregion

	public override void _Ready()
	{
		base._Ready();

		animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
		panel = GetNode<Panel>("CanvasLayer/Panel");
		panel.Modulate = Colors.Transparent;
		animationPlayer.AnimationFinished += OnAnimationFinishedHandler;

		buttonStart = GetNode<Button>("CanvasLayer/Control/MarginContainer/VBoxContainer/ButtonStart");
		buttonLoad = GetNode<Button>("CanvasLayer/Control/MarginContainer/VBoxContainer/ButtonLoad");
		buttonExit = GetNode<Button>("CanvasLayer/Control/MarginContainer/VBoxContainer/ButtonExit");

		buttonStart.Pressed += OnButtonStartPressedHandler;

		AudioManager.PlayBgm("start");
	}

	private void OnButtonStartPressedHandler()
	{
		AudioManager.PauseBgm();
		AudioManager.PlayEffect("click");
		// 加载新场景
		SceneManager.Instance.LoadScene(Path.SCENE_TEST);
	}

	private void OnAnimationFinishedHandler(StringName animName)
	{
		panel.Hide();
	}

}
